<template>
  <el-container>
    <el-aside width="600px">
      <el-form>
        <el-form-item>
          <el-date-picker v-model="startTm" type="date" placeholder="开始日期">
          </el-date-picker>
          <el-date-picker v-model="endTm" type="date" placeholder="截止日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-input
            type="textarea"
            autosize
            v-model="params"
            placeholder="上传参数（1可不填2多个参数;间隔开）"
          ></el-input>
        </el-form-item>
      </el-form>
      <el-form size="mini" :model="gms" :inline="true">
        <el-form-item v-for="(val, key) in gms" :key="key">
          <el-button @click="gmContent(key)">{{ val }}</el-button>
        </el-form-item>
      </el-form>
    </el-aside>
    <el-main>
      <el-input type="textarea" autosize v-model="content"></el-input>
    </el-main>
  </el-container>
</template>

<script>
import { jsLogReq, jsLogExecReq } from "../api/req";
export default {
  data() {
    let gms = {
      1: "hello",
      2: "world",
    };
    return {
      startTm: "",
      endTm: "",
      content: "hello world",
      params: "",
      gms: gms,
    };
  },
  created() {
    jsLogReq().then((res) => {
      this.gms = res;
    });
  },
  methods: {
    gmContent(key) {
      let reqObj = {
        startTm: this.startTm,
        endTm: this.endTm,
        key: key,
        params: this.params,
      };
      jsLogExecReq(reqObj).then((res) => {
        this.content = JSON.stringify(res, null, 2);
      });
    },
  },
};
</script>